package dto

import (
	"yunj/pkg/yunj/app/enum/admin/noticeenum"

	"github.com/worklz/go-validate"
)

// 后台顶部通知响应结构体
type AdminNoticeTopNoticeResponse struct {
	TypeList []*AdminNoticeUnreadListResponse `json:"type_list"`
}

type AdminNoticeUnreadListResponse struct {
	Type          uint8                        `json:"type"` // 未读通知类型
	TypeDesc      string                       `json:"type_desc"`
	Count         int64                        `json:"count"` // 未读通知数量
	Items         []*AdminNoticeUnreadListItem `json:"items"` // 未读通知数据
	PageSize      uint64                       `json:"page_size"`
	ViewMoreUrl   string                       `json:"view_more_url"`   // 查看更多地址
	ViewMoreTitle string                       `json:"view_more_title"` // 查看更多标题
}

type AdminNoticeUnreadListItem struct {
	Id        string `json:"id"`
	Type      uint8  `json:"type"` // 未读通知类型
	Desc      string `json:"desc"`
	Icon      string `json:"icon"`
	CreatedAt string `json:"created_at"`
	ViewUrl   string `json:"view_url"`   // 查看跳转地址
	ViewTitle string `json:"view_title"` // 查看跳转标题
	DataId    string `json:"-"`
}

// 未读列表请求数据
type AdminNoticeUnreadListData struct {
	validate.Validator
	Type uint8  `json:"type"`
	Page uint64 `json:"page"`
}

func (v *AdminNoticeUnreadListData) DefineRules() map[string]interface{} {
	rules := map[string]interface{}{
		"type": "required|in:" + noticeenum.TypeEnum.GetCommaSepConstStr(),
		"page": "required|positiveInt",
	}
	return rules
}

// 已读请求数据
type AdminNoticeReadData struct {
	validate.Validator
	Type uint8    `json:"type"`
	Ids  []string `json:"ids"`
}

func (v *AdminNoticeReadData) DefineRules() map[string]interface{} {
	rules := map[string]interface{}{
		"type": "required|in:" + noticeenum.TypeEnum.GetCommaSepConstStr(),
	}
	return rules
}
